package com.atguigu.day211105.exer;

import com.sun.corba.se.spi.legacy.connection.GetEndPointInfoAgainException;

public class Test1 {
    public static void main(String[] args) {
        Graphic[] arr = new Graphic[5];
        arr[0] = new Rectangle("re1", 4, 5);
        arr[1] = new Rectangle("re2", 3, 6);
        arr[2] = new Rectangle("re3", 3, 8);
        arr[3] = new Circle("c1", 4);
        arr[4] = new Circle("c2", 5);
        System.out.println("前:");
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i].getInfo());
        }
        for (int i = 1; i < arr.length; i++) {
            for (int j = 0; j < arr.length - i; j++) {
                if (arr[j].getArea() > arr[j + 1].getArea()) {
                    Graphic temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                }
            }
        }
        System.out.println("后:");
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i].getInfo());
        }
    }
}
